<?php
/**
 * Description of userclass
 *
 * @author Arco
 */
class Register {

    var $info;

    var $username;
    var $password;
    var $email;

    var $dead=false;
    var $melding;

    //deze functie word alleen voor registeren gebruikt, hoort hij dan wel hier te staan?
    function validateInfo($newUsername, $newPassword1, $newPassword2, $newEmail) {
        global $qm;
        $this->melding = "Fill the fields correct in.<br />";

        if(Validate::equals($newPassword1, $newPassword2)==true){
            if(Validate::checkLength($newPassword1, 6, 20)==true){
                $this->password=md5($newPassword1);
            }else{
                $this->dead=true;
                $this->melding .= "The password is to short or to long (6-20 characters)<br />";
            }
        }else{
            $this->dead=true;
            $this->melding .= "The passwords are not the same.<br />";
        }

        if(Validate::checkLength($newUsername, 2, 20)==true){
            if(Validate::checkUser($newUsername)==false){
                $this->username = $newUsername;
            }else{
                $this->dead=true;
                echo "This username already excistst.<br />";
            }
        }else{
            $this->dead=true;
            echo "Your username is to short or to long (6-20 characters)<br />";
        }

        if(Validate::checkEmail($newEmail)==false){
            $this->email=$newEmail;
        }else{
            $this->dead=true;
            $this->melding .= "This email is already in use.<br />";
        }
        if($this->dead==false) {
            $this->info = array($this->username, $this->password, $this->email);
            $this->melding = $qm->registerUser($this->info);
        }
        return $this->melding;
    }
}
?>